package com.en.sharing.stringconcat;

/**
 * 字符串连接测试
 *
 * @author 付晓飞
 * @date 2024/3/13 7:40 下午
 */
public class StringConcatTest {

    public void concat1() {
        String a = "a" + "b" + "c";
        System.out.println(a);
    }

    public void concat2() {
        String a = "a" + "b" + "c";
        String b = a + "b" + "c";
        System.out.println(b);
    }

    public void concat3() {
        String a = "a";
        for (int i = 0; i < 3; i++) {
            a = a + i;
        }
        System.out.println(a);
    }

    public void concat4() {
        String a = "a";
        String d = "d";
        StringBuilder sb = new StringBuilder();
        sb.append("b" + a).append("c" + d).append("e" + 1);
        System.out.println(sb);
    }

    public void concat5() {
        String a = "a";
        String d = "d";
        StringBuilder sb = new StringBuilder();
        sb.append("b").append(a).append("c").append(d).append("e").append(1);
        System.out.println(sb);
    }
}
